package com.rkl.test2;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rkl.dao.UserDao;



@Service
public class UserService {
	@Autowired
	private UserDao dao;
	public void setDao(UserDao dao) {
		this.dao = dao;
	}

	public int loginUser(String name, String password, HttpSession session) {
		User user = dao.findUserByName(name);
		if(user == null) {
			return App.USERNAME_EROOR;
		}else{
			if(user.getPassword().equals(password)) {
				return App.PWD_EROOR;
			}else {
				session.setAttribute("user", user);
				return App.LOGIN_OK;
			}
		}
		
	}

}
